//
//  PartyerShowDetailController.m
//  UESTCPioneer
//
//  Created by Apple on 14-9-25.
//  Copyright (c) 2014年 Sway. All rights reserved.
//

#import "PartyerShowDetailController.h"

@interface PartyerShowDetailController ()
{
    PartyerShowEntity * _entity;
    UIImageView *  _imageView;
}
@end

@implementation PartyerShowDetailController

-(id)initWithEntity:(PartyerShowEntity *)entity{

    if (self) {
        _entity = entity;
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithRed:235.0f/255.0f green:235.0f/255.0f blue:241.0f/255.0f alpha:1];
    //1.添加图片
    [self setImageView];
    //2.添加文本标签
    [self setContentText];
    //3.添加简介
    [self setBriefText];
    self.title = @"党员风采";
}

-(void)setImageView{
    
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 15, 80, 90)];
    imageView.contentMode = UIViewContentModeScaleAspectFill;
    imageView.clipsToBounds = YES;
    [self.view addSubview:imageView];
    
    NSString * imageName = [NSString stringWithFormat:@"%@%@",baseUrl,_entity.picUrl];
    NSURL * imageURL = [NSURL URLWithString:imageName];
    [imageView setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"image_default_big.png"] options:SDWebImageLowPriority | SDWebImageRetryFailed];
    _imageView = imageView;
    
    CGFloat y = CGRectGetMaxX(_imageView.frame) + 19;
    UIView *bar = [[UIView alloc] initWithFrame:CGRectMake(0, y, self.view.frame.size.width, 1)];
    bar.backgroundColor = [UIColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:1];
    [self.view addSubview:bar];
}

-(void)setBriefText{
    
    CGFloat width = CGRectGetMaxX(_imageView.frame) + 20;
    UILabel * brifLabel = [[UILabel alloc] initWithFrame:CGRectMake(width, 10, self.view.frame.size.width - width - 10, 80)];
    brifLabel.text = _entity.brief;
    brifLabel.numberOfLines = 0;
    brifLabel.font = [UIFont systemFontOfSize:17.0f];
//    brifLabel.lineBreakMode = NSLineBreakByWordWrapping;
    [self.view addSubview:brifLabel];
}

-(void)setContentText{

    CGFloat height = CGRectGetMaxY(_imageView.frame) + 5;
//    UILabel * content = [[UILabel alloc] initWithFrame:CGRectMake(10, height, self.view.frame.size.width - 20, self.view.frame.size.height - height)];
//    content.numberOfLines = 0;
//    content.lineBreakMode = NSLineBreakByWordWrapping;
//    content.text = _infoDict[@"content"];
//    [content sizeToFit];//顶部对齐
//    [self.view addSubview:content];
    
    UITextView * textView = [[UITextView alloc] initWithFrame:CGRectMake(10, height, self.view.frame.size.width - 20, self.view.frame.size.height - height - 58)];
    textView.text = _entity.content;
    textView.editable = NO;
    textView.font= [UIFont systemFontOfSize:16.0f];
    textView.backgroundColor = [UIColor colorWithRed:235.0f/255.0f green:235.0f/255.0f blue:241.0f/255.0f alpha:1];
    [self.view addSubview:textView];
    
}

@end
